from base.controllers import JsonController
from google.appengine.ext import db
from google.appengine.api import users
from common import validators
from datetime import datetime
from common import settings
from services.serialize import serialize_entity
import logging


class ExampleController(JsonController):
	def prepare(self):
		self.expect_field("phone_number", "p", [validators.RequiredValidator(), validators.PhoneNumberValidator()])

	def handle_request(self):
		phone_number = self.safe_values.get("phone_number")
		self.response.out.write("Got a phone number!")

		# Here is an example of how to use the framework

		# from model import business
		# business_obj = business.get_by_phone_number(phone_number) 
		# if business_obj:
		# 	self.response.out.write(serialize_entity(business_obj)) # Returns the entity as JSON
		# else:
		#	self.errors.append("Unable to find a business with phone number %s." % phone_number)

